import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export const saveAttachment = async (input: {
  message_id: number;
  type: number; // 1图片 2语音 3文件 4视频
  url: string;
  name?: string;
  size?: number;
  mime?: string;
}) => {
  return prisma.attachments.create({ data: input });
};

export const getAttachmentByMessage = async (message_id: number, name: string, type: number) => {
  return prisma.attachments.findUnique({ where: { message_id, name, type} });
};
